package edu.mq.itec814.tests

import edu.mq.itec814._

object SequentialImplementation extends Computation {
  
  def compute (list : List[Data]) : Int = list.map{f}.max
  
  def compute (array : Array[Data]) : Int = array.map{f}.max
  
}

object ParallelImplementation extends Computation {
  
  def compute (list : List[Data]) : Int = list.par.map{f}.par.max
  
  def compute (array : Array[Data]) : Int = array.par.map{f}.par.max
  
}

object ParallelExperimentation {

   def main(args: Array[String]) {
    
  	 Data(args(0).toInt)
  	 val list = Data.getList
  	 val arrayVals = Data.getArray 
  	 
  	 var t1 = System.currentTimeMillis()
  	 SequentialImplementation.compute(list)
  	 var t2 = System.currentTimeMillis()
   
  	 println("Sequential List " + (t2-t1) + " (ms)")
   
  	 t1 = System.currentTimeMillis()
  	 ParallelImplementation.compute(list)
  	 t2 = System.currentTimeMillis()
   
  	 println("Parallel List " + (t2-t1) + " (ms)")
    	
  	 t1 = System.currentTimeMillis()
  	 ParallelImplementation.compute(arrayVals)
  	 t2 = System.currentTimeMillis()
   
  	 println("Parallel Array " + (t2-t1) + " (ms)")
    
  	 val messageSender = new MessageSender(list)
  	 messageSender.start
  	 messageSender.doComputation
  }
  
}